# -*- coding: utf-8 -*-
from si_4k.sistema.models import *
from django.contrib.sites.models import Site
from django import template
from datetime import datetime
from decimal import *

register = template.Library()

@register.filter
def aula_paga(id_aula, id_aluno):
    aula = Aula.objects.get(id=id_aula)
    aluno = Aluno.objects.get(id=id_aluno)
    status_aula = StatusAula.objects.filter(aluno=aluno).get(aula=aula)
    return status_aula.pago

@register.filter
def var_str(var):
    return str(var)

@register.filter
def ver_endereco(id_aula):
    aula = Aula.objects.get(id=id_aula)
    if aula.local.nome == 'Casa do Aluno':
        return aula.aluno.all()[0].endereco
    else:
        return '4k Educacional'
    
#def duracao_aula(id_aula):
 #   aula = Aula.objects.get(id=id_aula)
  #  delta = aula.fim - aula.inicio
   # return Decimal(delta.seconds)/3600
    
@register.filter
def calculo_aula(aula):
    delta = aula.fim - aula.inicio
    delta = Decimal(delta.seconds)/3600
    valor_aula = delta*Decimal(aula.professor.valor)
    return valor_aula